<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>MockClock (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">testing.MockClock</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="class_goog_Disposable.html">
          goog.Disposable
</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Class for unit testing code that uses setTimeout and clearTimeout.

NOTE: If you are using MockClock to test code that makes use of
      goog.fx.Animation, then you must either:

1. Install and dispose of the MockClock in setUpPage() and tearDownPage()
   respectively (rather than setUp()/tearDown()).

or

2. Ensure that every test clears the animation queue by calling
   mockClock.tick(x) at the end of each test function (where `x` is large
   enough to complete all animations).

Otherwise, if any animation is left pending at the time that
MockClock.dispose() is called, that will permanently prevent any future
animations from playing on the page.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_testing_mockclock.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/testing/mockclock.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td><span class="type"><a href="class_goog_Disposable.html">goog.Disposable</a></span></td><td></td></tr>
  <tr><td>goog.testing.MockClock</td><td><span class="type"><a href="class_goog_Disposable.html">goog.Disposable</a></span></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.testing.MockClock(<span><span class="arg">opt_autoInstall</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_autoInstall</span>
        : <span class="type">boolean=</span>
        <div class="entryOverview">Install the MockClock at construction time.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_testing_MockClock.html">
              goog.testing.MockClock
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.cancelRequestAnimationFrame_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">cancelRequestAnimationFrame_<span class="args">(<span class="arg">timeoutKey</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Clears a requestAnimationFrame.
Mock implementation for cancelRequestAnimationFrame.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeoutKey</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The requestAnimationFrame key to clear.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line532">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.clearInterval_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">clearInterval_<span class="args">(<span class="arg">timeoutKey</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Clears an interval.
Mock implementation for clearInterval.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeoutKey</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The interval key to clear.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line521">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.clearTimeout_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">clearTimeout_<span class="args">(<span class="arg">timeoutKey</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Clears a timeout.
Mock implementation for clearTimeout.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeoutKey</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The timeout key to clear.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line494">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.disposeInternal"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposeInternal<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line220">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.fireResetEvent"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">fireResetEvent<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Signals that the mock clock has been reset, allowing objects that
maintain their own internal state to reset.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line247">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.getCurrentTime"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getCurrentTime<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The MockClock's current time in milliseconds.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line301">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.getTimeoutDelay"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getTimeoutDelay<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            delay The amount of time between when a timeout is
    scheduled to fire and when it actually fires, in milliseconds.  May
    be negative.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line267">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.getTimeoutsMade"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getTimeoutsMade<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of timeouts that have been scheduled.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line293">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.install"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">install<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Installs the MockClock by overriding the global object's implementation of
setTimeout, setInterval, clearTimeout and clearInterval.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.isTimeoutSet"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isTimeoutSet<span class="args">(<span class="arg">timeoutKey</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeoutKey</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The timeout key.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the timer has been set and not cleared,
    independent of the timeout's expiration.  In other words, the timeout
    could have passed or could be scheduled for the future.  Either way,
    this function returns true or false depending only on whether the
    provided timeoutKey represents a timeout that has been set and not
    cleared.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line315">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.replaceRequestAnimationFrame_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">replaceRequestAnimationFrame_<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Installs the mocks for requestAnimationFrame and cancelRequestAnimationFrame.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line174">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.requestAnimationFrame_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">requestAnimationFrame_<span class="args">(<span class="arg">funcToCall</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Schedules a function to be called when an animation frame is triggered.
Mock implementation for requestAnimationFrame.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">funcToCall</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function to call.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of timeouts created.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line462">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.reset"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">reset<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Resets the MockClock, removing all timeouts that are scheduled and resets
the fake timer count.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line232">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.runFunctionsWithinRange_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">runFunctionsWithinRange_<span class="args">(<span class="arg">endTime</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Runs any function that is scheduled before a certain time.  Timeouts can
be made to fire early or late if timeoutDelay_ is non-0.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">endTime</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The latest time in the range, in milliseconds.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line326">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.scheduleFunction_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">scheduleFunction_<span class="args">(<span class="arg">timeoutKey</span>,&nbsp;<span class="arg">funcToCall</span>,&nbsp;<span class="arg">millis</span>,&nbsp;<span class="arg">recurring</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Schedules a function to be run at a certain time.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeoutKey</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The timeout key.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">funcToCall</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function to call.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">millis</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The number of milliseconds to call it in.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">recurring</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
        <div class="entryOverview">Whether to function call should recur.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line359">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.setImmediate_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setImmediate_<span class="args">(<span class="arg">funcToCall</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Schedules a function to be called immediately after the current JS
execution.
Mock implementation for setImmediate.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">funcToCall</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function to call.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of timeouts created.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line483">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.setInterval_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setInterval_<span class="args">(<span class="arg">funcToCall</span>,&nbsp;<span class="arg">millis</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Schedules a function to be called every <code> millis</code> milliseconds.
Mock implementation for setInterval.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">funcToCall</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function to call.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">millis</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The number of milliseconds between calls.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of timeouts created.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line448">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.setTimeoutDelay"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setTimeoutDelay<span class="args">(<span class="arg">delay</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Sets the amount of time between when a timeout is scheduled to fire and when
it actually fires.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">delay</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The delay in milliseconds.  May be negative.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line257">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.setTimeout_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setTimeout_<span class="args">(<span class="arg">funcToCall</span>,&nbsp;<span class="arg">millis</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Schedules a function to be called after <code> millis</code> milliseconds.
Mock implementation for setTimeout.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">funcToCall</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function to call.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">millis</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The number of milliseconds to call it after.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of timeouts created.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line427">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.tick"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">tick<span class="args">(<span class="arg">opt_millis</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Increments the MockClock's time by a given number of milliseconds, running
any functions that are now overdue.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_millis</span>
        : <span class="type">number=</span>
        <div class="entryOverview">Number of milliseconds to increment the counter.
    If not specified, clock ticks 1 millisecond.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            Current mock time in milliseconds.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line279">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.prototype.uninstall"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">uninstall<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Removes the MockClock's hooks into the global object's functions and revert
to their original values.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line208">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_Disposable.html">
              goog.Disposable
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.addOnDisposeCallback"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">addOnDisposeCallback<span class="args">(<span class="arg">callback</span>,&nbsp;<span class="arg">opt_scope</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Invokes a callback function when this object is disposed. Callbacks are
invoked in the order in which they were added.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">callback</span>
        : <span class="type">function(this:T</span>)<span>:?</span>
        <div class="entryOverview">The callback function.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_scope</span>
        : <span class="type">T=</span>
        <div class="entryOverview">An optional scope to call the callback in.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line211">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.dispose"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">dispose<span class="args">()</span>
        </span>
        &#8658; <span class="type">void</span>
      </div>


     <div class="entryOverview">
       Disposes of the object. If the object hasn't already been disposed of, calls
<code> #disposeInternal</code>. Classes that extend <code> goog.Disposable</code> should
override <code> #disposeInternal</code> in order to delete references to COM
objects, DOM nodes, and other disposable objects. Reentrant.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type">void</span>&nbsp;
            Nothing.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line172">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.disposeInternal"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposeInternal<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Deletes or nulls out any references to COM objects, DOM nodes, or other
disposable objects. Classes that extend <code> goog.Disposable</code> should
override this method.
Not reentrant. To avoid calling it twice, it must only be called from the
subclass' <code> disposeInternal</code> method. Everywhere else the public
<code> dispose</code> method must be used.
For example:
<pre class="lang-js prettyprint">
  mypackage.MyClass = function() {
    goog.base(this);
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    goog.base(this, 'disposeInternal');
  };
</pre>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line245">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td class="deprecated">
    <a name="goog.Disposable.prototype.getDisposed"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getDisposed<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class="deprecatedMessage">Use <code> #isDisposed</code> instead.</span>
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the object has been disposed of.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line160">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.isDisposed"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">isDisposed<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the object has been disposed of.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Disposable.prototype.registerDisposable"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">registerDisposable<span class="args">(<span class="arg">disposable</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Associates a disposable object with this object so that they will be disposed
together.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">disposable</span>
        : <span class="type"><a href="interface_goog_disposable_IDisposable.html">goog.disposable.IDisposable</a></span>
        <div class="entryOverview">that will be disposed when
    this object is disposed.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line199">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_testing_MockClock.html">
              goog.testing.MockClock
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line58">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.deletedKeys_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">deletedKeys_</span>
        : 
     </div>


     <div class="entryOverview">
       Map of deleted keys.  These keys represents keys that were deleted in a
clearInterval, timeoutid -&gt; object.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line125">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.nowMillis_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">nowMillis_</span>
        : 
     </div>


     <div class="entryOverview">
       The current simulated time in milliseconds.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line133">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.queue_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">queue_</span>
        : 
     </div>


     <div class="entryOverview">
       Reverse-order queue of timers to fire.

The last item of the queue is popped off.  Insertion happens from the
right.  For example, the expiration times for each element of the queue
might be in the order 300, 200, 200.


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line71">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.replacer_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">replacer_</span>
        : <span class="type"><a href="class_goog_testing_PropertyReplacer.html">goog.testing.PropertyReplacer</a></span>
     </div>


     <div class="entryOverview">
       PropertyReplacer instance which overwrites and resets setTimeout,
setInterval, etc. or null if the MockClock is not installed.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line116">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.timeoutDelay_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">timeoutDelay_</span>
        : 
     </div>


     <div class="entryOverview">
       Additional delay between the time a timeout was set to fire, and the time
it actually fires.  Useful for testing workarounds for this Firefox 2 bug:
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=291386">https://bugzilla.mozilla.org/show_bug.cgi?id=291386</a>
May be negative.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line144">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.prototype.timeoutsMade_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">timeoutsMade_</span>
        : 
     </div>


     <div class="entryOverview">
       Count of the number of timeouts made.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line107">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_Disposable.html">
              goog.Disposable
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.creationStack"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">creationStack</span>
        : 
     </div>


     <div class="entryOverview">
       If monitoring the goog.Disposable instances is enabled, stores the creation
stack trace of the Disposable instance.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line144">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.disposed_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">disposed_</span>
        : 
     </div>


     <div class="entryOverview">
       Whether the object has been disposed of.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line128">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.Disposable.prototype.onDisposeCallbacks_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">onDisposeCallbacks_</span>
        : 
     </div>


     <div class="entryOverview">
       Callbacks to invoke when this object is disposed.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_disposable_disposable.js.source.html#line136">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.MockClock.insert_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.MockClock.</span><span class="entryName">insert_<span class="args">(<span class="arg">timeout</span>,&nbsp;<span class="arg">queue</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Inserts a timer descriptor into a descending-order queue.

Later-inserted duplicates appear at lower indices.  For example, the
asterisk in (5,4,*,3,2,1) would be the insertion point for 3.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeout</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The timeout to insert, with numerical runAtMillis
    property.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">queue</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&gt;
        <div class="entryOverview">The queue to insert into, with each element
    having a numerical runAtMillis property.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line385">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.MAX_INT_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.MockClock.</span><span class="entryName">MAX_INT_</span>
        : 
     </div>


     <div class="entryOverview">
       Maximum 32-bit signed integer.

Timeouts over this time return immediately in many browsers, due to integer
overflow.  Such known browsers include Firefox, Chrome, and Safari, but not
IE.


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line416">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.MockClock.REQUEST_ANIMATION_FRAME_TIMEOUT"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.MockClock.</span><span class="entryName">REQUEST_ANIMATION_FRAME_TIMEOUT</span>
        : 
     </div>


     <div class="entryOverview">
       Default wait timeout for mocking requestAnimationFrame (in milliseconds).


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line99">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.testing.MockClock.superClass_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.MockClock.</span><span class="entryName">superClass_</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_mockclock.js.source.html#line58">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package testing</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="testing.MockClock"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
